package com.lxlg.lxlg_order.infra.mapper;

import com.lxlg.lxlg_order.infra.model.GoodsOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lxlg.lxlg_order.infra.model.parm.SkuIdAndMoney;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author kevin
 * @since 2022-04-28
 */
public interface GoodsOrderMapper extends BaseMapper<GoodsOrder> {
    @Select("SELECT oag.sku_id ,oag.goods_num 'sku_id_num',sum(oag.goods_pay_allprice) 'all_money',oag.merchant_id,oag.merchant_name from goods_order go\n" +
            "LEFT JOIN order_and_goods oag\n" +
            "on go.order_id=oag.order_id\n" +
            "WHERE go.order_state=#{order_payState_complate} and oag.goods_state=#{order_goodsState_pay} \n" +
            "AND go.sale_end_time < #{date1} AND go.sale_end_time > #{date0}\n" +
            "GROUP BY oag.sku_id,oag.merchant_id,oag.merchant_name,oag.goods_num")
    List<SkuIdAndMoney> collectDayStatement(@Param("order_payState_complate") Integer order_payState_complate,@Param("order_goodsState_pay") Integer order_goodsState_pay, @Param("date0") Date date0,@Param("date") Date date);
}
